package com.elong.spring.beanfactory;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;

import com.elong.spring.inject.Boss1;
import com.elong.spring.reflect.Car;

public class BeanFactoryTest {

    public static void main(String[] args) {
	ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
	Resource res = resolver.getResource("classpath:conf/core/beans.xml");
	BeanFactory bf = new XmlBeanFactory(res);
	System.out.println("init beanfactory");
	Car car = bf.getBean("car1", Car.class);
	System.out.println("car bean is ready for use");
	car.introduce();
	
	Car car5 = bf.getBean("car5", Car.class);
	car5.introduce();
	
	Car car6 = bf.getBean("car6", Car.class);
	car6.introduce();
	
	Boss1 boss1 = bf.getBean("boss1", Boss1.class);
	Car car7 = boss1.getCar();
	car7.introduce();
    }
}
